// 我的班级的点击效果
let classFlag = true
$('.operation a:nth-child(2)').click(function () {
    userFlag = true
    $('.my-user-operation').fadeOut()
    $('.operation a:nth-child(3)').css('color', '#666')
    $('.my-class-list').fadeToggle('fast')
    if (classFlag) {
        $(this).css('color', '#0e90d2')
        classFlag = false
    } else {
        $(this).css('color', '#666')
        classFlag = true
    }
})
// 用户操作的点击效果
let userFlag = true
$('.operation a:nth-child(3)').click(function () {
    classFlag = true
    $('.my-class-list').fadeOut()
    $('.operation a:nth-child(2)').css('color', '#666')
    $('.my-user-operation').fadeToggle('fast')
    if (userFlag) {
        $(this).css('color', '#0e90d2')
        userFlag = false
    } else {
        $(this).css('color', '#666')
        userFlag = true
    }
})
// 筛选的点击按钮
$('.blog-filter').click(() => {
    $('.select-list').fadeToggle('fastg')
    $('#caret').toggleClass('dropup-caret')
})
// 发布班级公告的点击效果
$('.announce-a').click(() => {
    $('.announce').fadeIn('slow')
})
$('.quxiao').click(() => {
    $('.announce').fadeOut('slow')
})
$('.cancel-btn').click(() => {
    $('.announce').fadeOut('slow')
})
// 显示单条公告
let showMyclassNewAnnounce = () => {
    $.ajax({
        type: 'get',
        url: '/showMyclassNewAnnounce',
        data: '',
        success: function (result) {
            if (result.length != 0) {
                let data = template('announce-new', {
                    list: result
                })
                $('.bjgg').html(data)
            }
        }
    })
}
showMyclassNewAnnounce()
// 显示单条博文
let showNewBlog = () => {
    $.ajax({
        type: 'get',
        url: '/showNewBlog',
        data: '',
        success: function (result) {
            if (result.length != 0) {
                let data = template('theNewBlog', {
                    list: result
                })
                $('.zxbw').html(data)
            }
        }
    })
}
showNewBlog()
// 发布公告
$('.announce-btn').click(() => {
    let data = $('#announce-form').serialize()
    $.ajax({
        type: 'post',
        url: '/addAnnounce',
        data: data,
        success: function (result) {
            if (result.msg == '发布公告成功') {
                alert(result.msg)
                location.reload()
            }
        }
    })
})